package com.flx.service.impl;

import com.flx.anno.OperateLog;
import com.flx.mapper.LoginMapper;
import com.flx.service.LoginService;
import entity.Login;
import exception.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * (Login)表服务实现类
 *
 * @author makejava
 * @since 2025-04-22 08:52:32
 */
@Service
public class LoginServiceImpl implements LoginService {

  @Autowired
  private LoginMapper loginMapper;

  @Override
  public Login userLogin(Login login) throws CustomException {
    // 判断当前用户是否存在
    Login user = loginMapper.getByUserName(login.getUserName());
    if (user == null) {
      throw new CustomException("用户不存在");
    }
    return loginMapper.userLogin(login);
  }

  @Override
  public void insertUser(Login login) {
      loginMapper.insertUser(login);
  }


  @OperateLog
  @Override
  public boolean delUser(String userName) {
    int i = loginMapper.delUser(userName);
    return i > 0;
  }
}
